package com.wangsb.code0401;

import java.io.Serializable;

/**
 * @Description: 其中学生的信息有：学号、姓名、年龄
 * @author: shenbing.wang@hand-china
 * @date: 2021年06月20日 14:45
 */
public class Student implements Serializable {
    private static final long serialVersionUID = 1234567890L;

    private String stuNo;
    private String stuName;
    private Integer stuAge;

    public Student() {
    }

    public Student(String stuNo, String stuName, Integer stuAge) {


        this.stuNo = stuNo;
        this.stuName = stuName;
        this.stuAge = stuAge;
    }

    public String getStuNo() {
        return stuNo;
    }

    public void setStuNo(String stuNo) throws AgeAndStuNoException {
        //规定学号必须在6-10个字符之间
        if (stuNo.length() > 10 || stuNo.length() < 6) {
            throw new AgeAndStuNoException("您输入的学号不合法");
        }
        this.stuNo = stuNo;
    }

    public String getStuName() {
        return stuName;
    }

    public void setStuName(String stuName) {
        this.stuName = stuName;
    }

    public Integer getStuAge() {
        return stuAge;
    }

    public void setStuAge(Integer stuAge) throws AgeAndStuNoException {
        //规定年龄必须在（0，130）之间
        if (stuAge < 0 || stuAge > 130) {
            throw new AgeAndStuNoException("您输入的年龄不合法");
        }
        this.stuAge = stuAge;
    }

    @Override
    public String toString() {
        return "|"+stuNo + "|"+"\t" +"|"+ stuName +"|"+ "\t\t" + "|"+stuAge+"|";
    }


}
